<?php

declare(strict_types=1);

use App\Migration\MigrationInterface;
use PDO;

return new class implements MigrationInterface {
    public function getId(): string
    {
        return '20250121000100_create_posts_table';
    }

    public function up(PDO $pdo): void
    {
        $pdo->exec(
            <<<'SQL'
            CREATE TABLE IF NOT EXISTS posts (
                id SERIAL PRIMARY KEY,
                title VARCHAR(255) NOT NULL,
                body TEXT NOT NULL,
                created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
            )
            SQL,
        );
    }

    public function down(PDO $pdo): void
    {
        $pdo->exec('DROP TABLE IF EXISTS posts');
    }
};
